package com.zr.daoImpl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.zr.dao.YgxxDao;
import com.zr.model.User;
import com.zr.util.JDBCUtil;





public class YgxxDaoImpl implements YgxxDao{

	@Override
	public User getuserxx(int eid) {
		 User u=new User();
		  StringBuffer sql=new StringBuffer(" select eid,epsw,employee.ename,eage,esex,eidcard, ");
		  sql.append(" eborn,enation,eaddress,eeducation,eintime,eposition,eremark, ");
		  sql.append(" dname FROM employee INNER JOIN department ");
		  sql.append(" ON employee.did=department.did WHERE eid=?");
		  Connection con=JDBCUtil.getConnection();
		  try {
			PreparedStatement pst=con.prepareStatement(sql.toString());
			pst.setInt(1, eid);
			ResultSet rs=pst.executeQuery();
			
			if(rs.next()){
				u.setUsernum(rs.getInt(rs.getInt("eid")));
				u.setUserpsw(rs.getString("epsw"));
				u.setUsername(rs.getString("ename"));
				u.setUserage(rs.getInt("eage"));
				u.setUsersex(rs.getString("esex"));
				u.setUseridcard(rs.getString("eidcard"));
				u.setUserborn(rs.getString("eborn"));
				u.setUsernation(rs.getString("enation"));
				u.setUseraddress(rs.getString("eaddress"));
				u.setUsereducation(rs.getString("eeducation"));
				u.setUserintime(rs.getString("eintime"));
				u.setUserpositon(rs.getString("eposition"));
				u.setUserremark(rs.getString("eremark"));
				u.setUserdepartment(rs.getString("dname"));

			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return u;
	}



}
